package com.sz.pc.utils;

import java.util.HashMap;
import java.util.Map;

import com.baomidou.mybatisplus.plugins.Page;
import com.sz.pc.entity.model.Pager;


/**
 * 后台页面工具类
 * @author Administrator
 *
 */
public class PageUtil {
	
	public static Page<Map<String,Object>> initPage(String gridPager){
		Pager pager = JsonUtil.getObjectFromJson(gridPager, Pager.class);
		Page<Map<String,Object>> page = new Page<Map<String,Object>>(pager.getNowPage(), pager.getPageSize());
		page.setCondition(pager.getParameters());
		return page;
	}
	
	public static Map<String, Object> dealPageReturn(Page<Map<String,Object>> page){
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("isSuccess", Boolean.TRUE);
		params.put("nowPage", page.getCurrent());
		params.put("pageSize",page.getSize());
		params.put("pageCount", page.getPages());
		params.put("recordCount", page.getTotal());
		params.put("startRecord", page.getOffsetCurrent());
		params.put("exhibitDatas",page.getRecords());
		return params;
	}
}
